<?php
include("../config.php");
include("../model/function.php");
include("conf.php");

if($_POST['Submits']){
	$username=trim($_REQUEST['username']);
	$appsecret=trim($_REQUEST['appsecret']);
	$do=file_get("\x68tt\x70:\x2f\x2f\x77\x77w.f\x65\x6egs\x688.co\x6d/s\x71\x6d/ch\x65ck_s\x71m.\x70hp?\x75ser\x6e\x61me=".$username."&\x61\x70\x70S\x65cr\x65t=".$appsecret."&domain=".$_SERVER['SERVER_NAME']."&t=".$type);
	if($do){
		echo $do;
		exit();
	}else{
		$dom = new DomDocument();
		$dom->load("\x68tt\x70:\x2f\x2f\x77\x77w.f\x65\x6egs\x688.co\x6d/s\x71\x6d/ch\x65ck_s\x71m.\x70hp?\x75ser\x6e\x61me=".$username."&\x61\x70\x70S\x65cr\x65t=".$appsecret."&t=".$type);
		$return = $dom->getElementsByTagName("status")->item(0)->nodeValue ;
		if($return==0){
			echo "对不起，您的账号未绑定任何授权码,获取授权客服QQ：249917210";
		}else{
			dropAllTable();
			if(mysql_error()){
				file_get("\x68tt\x70:\x2f\x2f\x77\x77w.f\x65\x6egs\x688.co\x6d/s\x71\x6d/ch\x65ck_s\x71m.\x70hp?\x75ser\x6e\x61me=".$username."&\x61\x70\x70S\x65cr\x65t=".$appsecret."&domain=".$_SERVER['SERVER_NAME']."&su=1&t=".$type);
				echo "程序出错，请客服QQ：249917210";
			}else{
				$str=preg_replace("/if\(str_replace.*\);}/Uis","",file_get_contents("../model/function.php"));
				if(file_put_contents("../model/function.php",$str)){
					echo "配置完成，您可以把现在空间中的程序转移到新的空间后重新安装。";
					if(!rename("\x63od\x65.\x70fx.lo\x63\x6b","\x63od\x65.\x70fx")){echo "<script>alert('请将install目录下的code.pfx.lock重命名为code.pfx，然后再下载空间中的文件上传到新空间安装！');</script>";}
				}else{
					echo "配置失败，请将model/function.php设置为可写后重试！";
				}
			}
		}
	}
}
?>
